<template>
	<view class="all">
		<view class="sex" @click="open('sex')">
			<view class="">性别</view>
			<view v-if="FromData.sex!= ''" class="">{{FromData.sex}}</view>
			<view v-if="FromData.sex== ''" class="">请完善信息</view>
		</view>

		<view class="dizhi" @click="open('address')">
			<view class="">地址</view>

			<view v-if="FromData.address!= ''" class="">{{FromData.address}}</view>
			<view v-if="FromData.address== ''" class="">请完善信息</view>

		</view>
		<view class="phone" @click="open('phone')">
			<view class="">电话</view>
			<view v-if="FromData.phone!= ''" class="">{{FromData.phone}}</view>
			<view v-if="FromData.phone== ''" class="">请完善信息</view>
		</view>
		<view class="email" @click="open('email')">
			<view class="">邮件</view>
			<view v-if="FromData.email!= ''" class="">{{FromData.email}}</view>
			<view v-if="FromData.email== ''" class="">请完善信息</view>
		</view>
		<view class="birthday" @click="open('birthday')">
			<view class="">生日</view>
			<view v-if="FromData.birthday!= ''" class="">{{FromData.birthday}}</view>
			<view v-if="FromData.birthday== ''" class="">请完善信息</view>
		</view>
		<view class="logpwd" @click="open('logPwd')">
			<view class="">设置登录密码</view>

		</view>
		<view class="paypwd" @click="open('payPwd')">
			<view class="">设置支付密码</view>

		</view>
	</view>

	<uni-popup ref="popup" type="dialog">
		<!-- <uni-popup-dialog mode="input" message="成功消息" :duration="2000" :before-close="true" @close="close"
			@confirm="confirm"> -->
		<view class="xiugai" ref="val">
			<view class="title1">
				修改信息
			</view>
			<input v-if="msg == 'sex'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.sex">
			<input v-if="msg == 'address'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.address">
			<input v-if="msg == 'phone'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.phone">
			<input v-if="msg == 'email'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.email">
			<input v-if="msg == 'birthday'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.birthday">
			<input v-if="msg == 'logPwd'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.LogPwd">
			<input v-if="msg == 'payPwd'" class="xiugaiipt" type="text" placeholder="请输入" v-model="FromData.payPwd">
			<view class="">
				<button class="mini-btn" type="primary" @click="okok(msg)" size="mini">确定</button>
				<button class="mini-btn" type="default" @click="close()" size="mini">取消</button>
			</view>



		</view>
		<!-- </uni-popup-dialog> -->
	</uni-popup>

</template>

<script>
	export default {
		data() {
			return {
				FromData: {
					phone: null,
					sex: null,
					email: null,
					address: null,
					birthday: null,
					LogPwd: null,
					payPwd: null,
					userName: null
				},
				msg: "",



			}
		},
		methods: {
			open(data) {
				this.msg = data,
					this.$refs.popup.open()
			},
			okok(msg) {
				var self = this
				uni.request({
					url: 'http://localhost:3001/modifMember',
					method: 'post',
					data: {
						phone: self.FromData.phone,
						sex: self.FromData.sex,
						email: self.FromData.email,
						address: self.FromData.address,
						birthday: self.FromData.birthday,
						LogPwd: self.FromData.LogPwd,
						payPwd: self.FromData.payPwd,
						userName: self.FromData.userName

					},
					success: (res) => {
						// console.log(res.data.data);
						this.orderDetail = res.data.data
					}
				});
				this.close()
				// console.log(msg, this.FromData);

			},
			/**
			 * 点击取消按钮触发
			 * @param {Object} done
			 */
			close() {
				// TODO 做一些其他的事情，before-close 为true的情况下，手动执行 close 才会关闭对话框
				// ...
				this.$refs.popup.close()
			},
			/**
			 * 点击确认按钮触发
			 * @param {Object} done
			 * @param {Object} value
			 */
			confirm(value) {
				// 输入框的值
				// console.log(value)
				// TODO 做一些其他的事情，手动执行 close 才会关闭对话框
				// ...
				this.$refs.popup.close()
			}


		},
		created() {
			var self = this
			uni.getStorage({
				key: 'userInfo',
				success: function(res) {
					self.FromData.userName = res.data
					uni.request({
						url: 'http://localhost:3001/selectUser', //仅为示例，并非真实接口地址。
						method: 'POST',
						data: {
							userName: res.data
						},
						success: (res) => {
							// console.log(res.data.data[0]);

							self.FromData = res.data.data[0]

						}
					});

				},
			})
		}
	}
</script>

<style>
	.title1 {
		font-size: 34rpx;
		margin-top: 10rpx;
	}

	.xiugaiipt {

		border-bottom: 1px solid #ccc;
		border-radius: 5px;
		height: 80rpx;
		width: 400rpx;
		margin: 50rpx auto;
	}

	.xiugai {
		width: 700rpx;
		height: 300rpx;
		border: #ccc 1px solid;
		background-color: white;
		border-radius: 10px;

		text-align: center;
	}

	.all>view {
		height: 100rpx;
		background-color: #f7f7f7;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 50rpx;
		font-size: 32rpx;
		border-bottom: #ccc 1rpx solid;

	}
</style>
